<template>
	<view>
		<view class="mix-product-list">
			<view class="list-item column" v-for="(item,index) in dataList" @click="itemClick(item)">
				<view class="image-wrapper lazypic">
					<image :src="item.goods_image" mode="aspectFill"></image>
				</view>
				<text class="title clamp2">{{item.goods_name}}</text>
				<view class="price-wrap row">
					<text v-if="showyongjin" class="m-price" style="margin-right: 5px;">
						<text v-if="member_level==3">{{item.market_price}}</text>
						<text v-else>{{(item.market_price*50/100).toFixed(2)}}</text>
					</text>
					<view class="mix-price-view">
						<text>￥</text>
						<text>{{item.price}}</text>
					</view>
					<view class="fill"></view>
					<view class="tag center">
						<text>免邮</text>
					</view>
				</view>
			</view>
		</view>
		<view style="color: #999;font-size: 14px;text-align: center;margin-top: 50%;background-color: #f7f7f7;"
			v-if="nodata">
			暂无数据~
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nodata: false,
				dataList: [],
				category_id: '',
				showyongjin: false,
				member_level: 0,
			};
		},
		onLoad(options) {
			if (options.uid) {
				//转发
				uni.setStorageSync('uid', options.uid);
			}
			this.category_id = ',' + options.category_id1 + ',' + options.category_id2 + ',';
			uni.setNavigationBarTitle({
				title: options.category_name
			})
			this.queryList(1, 1000);
		},
		onShow() {
			if (uni.getStorageSync('userInfo')) {
				if (uni.getStorageSync('userInfo').member_level > 1) {
					this.showyongjin = true;
					this.member_level = uni.getStorageSync('userInfo').member_level;
				}
			}
		},
		onShareAppMessage(res) {
			let path = getCurrentPages()
			let path_share = path[0].$page.fullPath
			let path_title = path[0].data.title
			if (uni.getStorageSync('userInfo')) {
				path_share = path_share + '?uid=' + uni.getStorageSync('userInfo').member_id
			}
			return {
				title: path_title,
				path: path_share,
			}
		},
		methods: {
			queryList(pageNo, pageSize) {
				this.$http.post('goods/categoryProductList', {
					pageno: pageNo,
					category_id: this.category_id
				}).then((res) => {
					this.dataList = res.data.data;
					if (res.data.data.length == 0) {
						this.nodata = true;
					} else {
						this.nodata = false;
					}
				})
			},
			itemClick(item) {
				this.navTo('/pages/product/detail?id=' + item.goods_id);
			}
		},
	};
</script>

<style lang='scss'>
	page {
		height: 100%;
		background-color: #f7f7f7;
	}

	/* 分类 */
	.cate-section {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding: 10rpx 16rpx;
		background: #fff;

		.item {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 20%;
			padding: 20rpx 0;
			font-size: 24rpx;
			color: #333;
		}

		.name {
			font-size: 12px;
		}

		.icon {
			width: 84rpx;
			height: 84rpx;
			margin-bottom: 14rpx;
			border-radius: 50%;
		}
	}

	.mid-ad {
		/* width: 100%; */
		height: 208rpx;
		padding: 0 20rpx 20rpx;
		background: #fff;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.hot-wrap {
		padding-top: 20rpx;
		background: linear-gradient(to bottom, #fff 10rpx, #f7f7f7);

		transition: opacity .2s;



		.floor-header {
			padding-bottom: 30rpx;
		}

		/deep/ .list-item {
			box-shadow: 4rpx 0 10rpx rgba(0, 0, 0, .06);
		}
	}

	.floor-header {
		padding: 6rpx 30rpx 8rpx 24rpx;
		font-size: 24rpx;
		color: #999;
		background-color: #fff;

		.icon {
			flex-shrink: 0;
			width: 80rpx;
			height: 80rpx;
			margin-right: 20rpx;
		}

		.tit-box {
			flex: 1;
			display: flex;
			flex-direction: column;
		}

		.tit {
			margin-bottom: 10rpx;
			font-size: 32rpx;
			color: #333;
			font-weight: 700;
		}

		.icon-you {
			font-size: 28rpx;
			color: #999;
		}
	}

	.mix-product-list {
		margin-top: 5px;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		width: 710rpx;
		margin-left: 20rpx;
		background-color: #f7f7f7;

		&.is-row {
			margin-top: -4rpx;
			border-radius: 8rpx;
			box-shadow: 4rpx 4rpx 20rpx rgba(0, 0, 0, .06);
			overflow: hidden;
		}
	}

	/* 竖向列表 */
	.mix-price-view {
		color: red;
	}

	.list-item.column {
		width: 350rpx;
		padding-bottom: 16rpx;
		margin-bottom: 12rpx;
		background: #fff;
		border-radius: 8rpx;
		overflow: hidden;
		box-shadow: 0 0 16rpx rgba(0, 0, 0, .06);
		position: relative;

		.image-wrapper {
			width: 100%;
			height: 350rpx;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.title {
			font-size: 28rpx;
			color: #333;
			line-height: 36rpx;
			padding: 0 16rpx;
			margin-top: 18rpx;
			height: 76rpx;
		}

		.price-wrap {
			padding: 0 16rpx;
			margin-top: 18rpx;
		}

		.m-price {
			font-size: 24rpx;
			/* text-decoration: line-through; */
			color: #999;
			margin-left: 10rpx;

			&:before {
				content: "￥";
			}
		}

		.tag {
			height: 32rpx;
			padding: 0 10rpx;
			font-size: 20rpx;
			background-color: $base-color;
			color: #fff;
			border-radius: 4rpx;
			transform: translateY(-4rpx);
		}
	}

	.btn {
		width: 44px;
		height: 40px;
		padding: 5px 12px;
		position: relative;

		.mix-icon {
			font-size: 20px;
			color: #333;
		}

		.msg {
			position: absolute;
			right: 7px;
			top: 5px;
			width: 12px;
			height: 12px;
			background-color: $base-color;
			border: 2px solid #fff;
			border-radius: 100px;
			opacity: 0;

			&.show {
				opacity: 1;
			}
		}
	}

	.search-wrap {
		flex: 1;
		font-size: 14px;
		color: #999;
		border-radius: 100px;
		background-color: #f2f2f2;

		.icon-sousuo {
			margin-right: 6px;
			font-size: 18px;
			color: #999;
		}
	}
</style>
